package com.uchengwang.ui.cm_ui.rychat.msgtype;

import android.content.Intent;
import android.support.v4.app.Fragment;

import com.uchengwang.ui.listener.PermissionsListener;
import com.uchengwang.ui.utils.PermissionUtils;
import com.uchengwang.ui.utils.UCommonUtil;

import io.rong.imkit.RongExtension;
import io.rong.imkit.plugin.ImagePlugin;
import io.rong.imkit.plugin.image.PictureSelectorActivity;
import io.rong.imlib.model.Conversation;

/**
 * Created by U城网 on 2018/3/13.
 */

public class ImageNewPlugin extends ImagePlugin {
    private Conversation.ConversationType conversationType;
    private String targetId;

    public ImageNewPlugin() {
    }

    @Override
    public void onClick(final Fragment currentFragment, final RongExtension extension) {
        PermissionUtils.getUtils().checkRead(currentFragment.getActivity(), new PermissionsListener() {
            @Override
            public void onSuccess() {
                conversationType = extension.getConversationType();
                targetId = extension.getTargetId();
                Intent intent = new Intent(currentFragment.getActivity(), PictureSelectorActivity.class);
                extension.startActivityForPluginResult(intent, 23, ImageNewPlugin.this);
            }

            @Override
            public void onFailed() {
                UCommonUtil.getUtil().showToast(currentFragment.getContext(), "请授权获取文件的权限");
            }
        });

    }

    public void onActivityResult(int requestCode, int resultCode, Intent data) {
    }
}
